package com.huangliusong.aspect;

import java.util.Date;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class TimerAspect {

	@Around("execution(* com.huangliusong.web.controller.UserController.*(..))")
	public Object handleControllerMethod(ProceedingJoinPoint point) throws Throwable {
		System.err.println("time aspect start");
		Object[] args = point.getArgs();
		for (Object arg : args) {
			System.err.println("arg is " + arg);
		}
		long start = new Date().getTime();
		Object object = point.proceed();
		System.err.println("time aspect 耗时：" + (new Date().getTime() - start));
		System.err.println("time aspect end");
		return object;
	}

}
